<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>watch option</title>
    <script type="text/javascript" src="../assests/js/vue.js"></script>
</head>
<body>
    <h1>watch option</h1>
    <hr>
    <div id="app">
        <p>今日天气：{{ wenduTxt }}</p>
        <p>建议穿衣：{{ chuanyi }}</p>
        <p>
            <button @click="up()">升温</button>   
            <button v-on:click="down()">降温</button>   
        </p>
    </div>
    <script>
        var list = ["短裙短袖","夹克衬衫","棉衣羽绒服"];
        var app = new Vue({
            el:"#app",
            data:{
                wendu:20,
                chuanyi:"夹克衬衫"
            },
            methods:{
                up: function(){
                    this.wendu += 5;
                },
                down:function(){
                    this.wendu -= 5;
                }
            },
            computed:{
                wenduTxt:function(){
                    return this.wendu+"℃";
                }
            },
            watch:{
                wendu:function(newVal,oldVal){
                    if(newVal>26){
                        this.chuanyi = list[0];
                    }else if(newVal<=26 && newVal > 0){
                        this.chuanyi = list[1];
                    }else{
                        this.chuanyi = list[2];
                    }
                }
            }
        })
    </script>
</body>
</html>